package cn.yeziji.forum.bo.chatroom;

import cn.yeziji.forum.common.Msg;
import cn.yeziji.forum.common.websocket.Chatroom;

import java.util.List;
import java.util.Objects;

/**
 * 系统信息数据传输对象
 *
 * @author gzkemays
 * @date 2022/4/25
 */
public class SystemMsgBO extends Msg {
  List<String> userIds;
  List<String> userNames;

  public SystemMsgBO build(Chatroom chatroom) {
    this.key = Chatroom.SYSTEM;
    this.msg = chatroom.getMsg();
    this.to = chatroom.getTo();
    this.from = Chatroom.SYSTEM_FROM;
    this.timestamp = System.currentTimeMillis();
    this.chatroom = buildChatroom();
    return this;
  }

  public SystemMsgBO build(String msg) {
    SystemMsgBO systemMsgBO = new SystemMsgBO();
    systemMsgBO.setKey(Chatroom.SYSTEM);
    systemMsgBO.setMsg(msg);
    Objects.requireNonNull(to);
    systemMsgBO.setChatroom(to);
    systemMsgBO.setFrom(Chatroom.SYSTEM_FROM);
    systemMsgBO.setTimestamp(System.currentTimeMillis());
    systemMsgBO.setChatroom(buildChatroom());
    return systemMsgBO;
  }
}
